Repository navigation
Return a missing identifier from parseDecoratedExpression instead of a missing declaration - #65496
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
Malformed decorators can reach expression parsing without a following class. Returning a missing declaration puts a non-expression node in assignment and decorator expression slots. Use the existing missing identifier recovery node while retaining the expression diagnostic. Cover recovery in assignments, asynchronous iteration, and destructuring through compiler baselines.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the decorated-expression recovery change.
No open issues 🎉
What changed in this PR
This PR corrects error recovery in the native TypeScript parser: malformed decorated expressions now produce a missing identifier rather than a declaration, preserving the expected expression node kind.
Changes:
- Updates
parseDecoratedExpressionto return a missing identifier. - Adds regression coverage for malformed decorators in assignments,
for awaitloops, and destructuring. - Updates diagnostic, emit, type, and symbol baselines to reflect the revised recovery behavior.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/decoratorMissingClassExpression.ts |
Adds malformed decorated-expression regression cases. |
tsc/testdata/baselines/reference/conformance/decoratorOnFunctionExpression.types |
Updates recovered function-expression types. |
tsc/testdata/baselines/reference/conformance/decoratorOnFunctionExpression.symbols |
Removes the discarded decorator’s symbol entry. |
tsc/testdata/baselines/reference/conformance/decoratorOnArrowFunction.types |
Records recovered arrow-function types. |
tsc/testdata/baselines/reference/conformance/decoratorOnArrowFunction.symbols |
Records the missing parameter’s symbol. |
tsc/testdata/baselines/reference/conformance/decoratorOnArrowFunction.js |
Updates recovered arrow-function emit. |
tsc/testdata/baselines/reference/conformance/decoratorOnArrowFunction.errors.txt |
Updates arrow-function recovery diagnostics. |
tsc/testdata/baselines/reference/compiler/decoratorMissingClassExpression.types |
Adds regression type baselines. |
tsc/testdata/baselines/reference/compiler/decoratorMissingClassExpression.symbols |
Adds regression symbol baselines. |
tsc/testdata/baselines/reference/compiler/decoratorMissingClassExpression.js |
Adds regression JavaScript emit baselines. |
tsc/testdata/baselines/reference/compiler/decoratorMissingClassExpression.errors.txt |
Adds expected regression diagnostics. |
tsc/internal/parser/parser.go |
Returns a missing identifier for invalid decorated expressions. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This was incorrect; a declaration is of course not an expression.